<?php

/** Report prg file (productos) 
 *  
 *  Dynamically created by ycube plus RAD
 *  
 *  USE THIS FILE TO PERSONALIZE A PROGRAM SIDE OF YOUR REPORT
 *  ==========================================================
 */  

// ATTENTION: CANCEL THIS BLOCK TO EDIT A FILE 
$T = new Y_Template( $file_tpl ); 
// Superior Variables
$T->Set( 'sup___msg', '( ! ) Utilize el comodin % adelante, atras o en ambos para buscar mas facilmente ');
$T->Set( 'sup___lock', 'true');
$T->Set( 'sup_descrip', 'Bulon p/mad BMW%');
$T->Set( 'sup_precio', '');
$T->Set( 'sup_indice0', '0');
$T->Set( 'sup_indice1', '120');
$T->Set( 'sup_order', 'CODIGO');
$T->Set( 'sup_preview', '');
// ------------------------------------------

// THIS IS YOUR FIRST QUERY:
//$query0 = "SELECT INDICE, CODIGO, DESCRIP AS DESCRIPCION, EQUIV, PRECIO from productos where descrip like 'Bulon p/mad BMW%' and precio LIKE '%' and INDICE BETWEEN '0' / 1 AND '120' / 1 order by 'CODIGO' ";

$T->Set( 'time', daytime() );
$T->Set( 'user', $Global['username'] );

$firstRow=true;
$Q0 = $DB;
$Q0->Query( $query0 );

// Starting a HTML
$T->Show('general_header');			// Principal Header
$T->Show('start_query0');			// Start a Table 
$T->Show('header0');				// Show Header

//Define a  variable
$endConsult = false;
//Define a Total Variables

//Define a Subtotal Variables


//Define a Old Values Variables
$old['INDICE'] = '';
$old['CODIGO'] = '';
$old['DESCRIPCION'] = '';
$old['EQUIV'] = '';
$old['PRECIO'] = '';

// Making a rows of consult
while( $Q0->NextRecord() ){

    // Define a elements
    $el['INDICE'] = $Q0->Record['INDICE'];
    $el['CODIGO'] = $Q0->Record['CODIGO'];
    $el['DESCRIPCION'] = $Q0->Record['DESCRIPCION'];
    $el['EQUIV'] = $Q0->Record['EQUIV'];
    $el['PRECIO'] = $Q0->Record['PRECIO'];

    // Preparing a template variables
    $T->Set('query0_INDICE', $el['INDICE']);
    $T->Set('query0_CODIGO', $el['CODIGO']);
    $T->Set('query0_DESCRIPCION', $el['DESCRIPCION']);
    $T->Set('query0_EQUIV', $el['EQUIV']);
    $T->Set('query0_PRECIO', $el['PRECIO']);

    // Calculating a total

    // Calculating a subtotal

    $T->Show('query0_data_row');
    // Show Subtotal
    if( true ){
        $T->Show('query0_subtotal_row');
        //Reset a Subtotal Variables
    }
    
    //Actualize Old Values Variables
    $old['INDICE'] = $el['INDICE'];
    $old['CODIGO'] = $el['CODIGO'];
    $old['DESCRIPCION'] = $el['DESCRIPCION'];
    $old['EQUIV'] = $el['EQUIV'];
    $old['PRECIO'] = $el['PRECIO'];
    $firstRow=false;

}

$endConsult = true;
if( true ){
    $T->Show('query0_subtotal_row');
}
// Show total
if( true ){
    $T->Show('query0_total_row');
}
$T->Show('end_query0');				// Ends a Table 

?>
